<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
    <title>hu_subsidy_category</title>
    <meta name="decorator" content="form"/>
	<link href="/static/common/css/web/from.css" rel="stylesheet">
    <html:css name="bootstrap-fileinput" />
    <html:css name="simditor" />

</head>

<body class="white-bg"  formid="huSubsidyCategoryForm">
    <form:form id="huSubsidyCategoryForm" modelAttribute="data" method="post" class="form-horizontal">
	<div class="content-bottom">
		<!-- 下拉选择 -->
		<div class="content-li content-Select">
			<div class="content-left">
				补贴类别：
			</div>
			<div class="content-right">
				<select id="categoryId" >
					<option value="0">请选择</option>
					<option  value="1">培训类别</option>
					<option  value="2">就业类别</option>
				</select>

			</div>
			<input type="hidden" id="cateName" name="cateName">
		</div>
		<!-- 输入框 -->
		<div class="content-li content-Input">
			<div class="content-left">
				补贴金额：
			</div>
			<div class="content-right">
				<input type="text" id="suMoney" name="suMoney">
			</div>
		</div>
		<!-- 输入框 -->
		<div class="content-li content-Input">
			<div class="content-left">
				备注：
			</div>
			<div class="content-right">
				<input type="text" id="remarks" name="remarks">
			</div>
		</div>
	</div>
	</div>
	</form:form>
<html:js name="bootstrap-fileinput" />
<html:js name="simditor" />
<script type="text/javascript">
    $("#categoryId").change(function () {
        if($(this).val()==2){
            var employType=['转移就业','自主创业','特设公益性岗位','公益专岗','公益性岗位'];
            $("#categoryId").siblings().remove();
            var selectHtml='<select class="select2" id="childrenId" onchange="changeText(this)">'
                +'<option value="0">请选择</option>';
            for(var i=0;i<employType.length;i++){
                var j=1+i;
                selectHtml+='<option value="'+j+'">'
                    +employType[i]
                    +'</option>';
            }
            selectHtml+='</select>';
            $("#categoryId").parent().append(selectHtml);
        }if($(this).val()==1){
            $.ajax({
                type:"get",
                url:"/admin/labor/hutraincategory/selectList",
                success:function (data) {
                    $("#categoryId").siblings().remove();
                    var selectHtml='<select class="select2" id="childrenId" onchange="changeChildrenId(this)">'
                        			+'<option value="0">请选择</option>';
                    for(var i=0;i<data.length;i++){
                        selectHtml+='<option value="'+data[i].id+'">'
                            +data[i].cateName
                            +'</option>';
                    }
                    selectHtml+='</select>';
                    //$(this).siblings(selectHtml);
                    //$(selectHtml).appendTo("#categoryId");
                    $("#categoryId").parent().append(selectHtml);
                },
                error : function() {
                    toastr.error('Error');
                },
            })
		}if($(this).val()==0){
            $("#categoryId").siblings().remove();
		}
    });
    function changeChildrenId(o) {
        if($(o).val()==0){
            $("#categoryId").siblings().eq(1).remove();
		}else {
        	$.ajax({
            	type:"get",
            	url:"/admin/labor/husubjectcategory/selectList?id="+$(o).val(),
            	success:function (data) {
                	$("#categoryId").siblings().eq(1).remove();
                	var selectHtml='<select onchange="changeText(this)" class="select2" name="cateId">'
                   		+'<option>请选择</option>';
                	for(var i=0;i<data.length;i++){
                    	selectHtml+='<option value="'+data[i].id+'">'
                        	+data[i].cateName
                        	+'</option>';
                	}
                	selectHtml+='</select>';
              	  	$("#categoryId").parent().append(selectHtml);
          	  	},
           	 	error : function() {
             	   toastr.error('Error');
            	},
        })
        }
    }
    function changeText(o) {
        if($(o).val()==0){
            $("#categoryId").siblings().eq(1).remove();
        }else {
            $.ajax({
                type:"get",
                url:"/admin/labor/huemploycate/selectList?transRang="+$(o).val(),
                success:function (data) {
                    $("#categoryId").siblings().eq(1).remove();
                    var selectHtml='<select class="select2"  name="cateId">'
                        +'<option>请选择</option>';
                    for(var i=0;i<data.length;i++){
                        selectHtml+='<option value="'+data[i].id+'">'
                            +data[i].transferCate
                            +'</option>';
                    }
                    selectHtml+='</select>';
                    // $(this).siblings(selectHtml);
                    //$(selectHtml).appendTo("#categoryId");
                    $("#categoryId").parent().append(selectHtml);
                },
            })
		}

      //  $("#cateName").val($(o).find("option:selected").text());
    }
</script>
</body>
</html>